import pandas as pd
import seaborn as sns
from sklearn.metrics import confusion_matrix, accuracy_score, precision_score, recall_score, f1_score, \
    classification_report

label = ["猫", "狗"]  # 标签
y_true = ["猫", "猫", "猫", "猫", "猫", "猫", "狗", "狗", "狗", "狗"]  # 真实值
y_pred1 = ["猫", "猫", "狗", "猫", "猫", "猫", "猫", "猫", "狗", "狗"]  # 预测值

matrix1= confusion_matrix(y_true, y_pred1)
print(pd.DataFrame(matrix1, columns=label, index=label))
sns.heatmap(matrix1, annot=True, fmt='d', cmap="Greens")

accuracy = accuracy_score(y_true, y_pred1)
print(accuracy)

precision = precision_score(y_true, y_pred1, pos_label="猫")
print(precision)

recall = recall_score(y_true, y_pred1, pos_label="猫")
print(recall)

f1 = f1_score(y_true, y_pred1, pos_label="猫")
print(f1)


report = classification_report(y_true, y_pred1)
print(report)